using System.Net.Mail;
using Headspring.Training.Core.Services.Impl;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace Headspring.Training.UnitTests.Services
{
	[TestFixture]
	public class SmtpNotifierTester
	{
		private class TestSmtpNotifier : SmtpNotifier
		{
			public MailMessage Message;

			protected override void sendMailMessage(MailMessage message,
			                                        SmtpClient client)
			{
				Message = message;
			}
		}

		[Test]
		public void ShouldMakeMessageCorrectly()
		{
			var notifier = new TestSmtpNotifier();
			notifier.Send("foo@foo.com", "bar");

			MailMessage message = notifier.Message;
			Assert.That(message, Is.Not.Null);
			Assert.That(message.To.ToString(), Is.EqualTo("foo@foo.com"));
			Assert.That(message.Body, Is.EqualTo("bar"));
			Assert.That(message.Subject, Is.EqualTo("notification"));
			Assert.That(message.From.ToString(), Is.EqualTo("no-reply@google.com"));
		}
	}
}